Skip to content

Storybook: a whole custom host UI on the core alone - #120

Merged
agorischek merged 7 commits into
mainfrom
custom-host-story
Nov 21, 2026
Merged

agorischek merged 7 commits into
mainfrom
custom-host-story

Conversation

@agorischek

Copy link
Copy Markdown
Collaborator

Stacked on #119. This is item G11 of the headless-host plan ("docs and examples"), its example half.

Why

The only "core alone" examples were a 10-line snippet in docs/guides/embedding.md and Core/Projection stage, a find field, a mode select and a slider. Nothing showed a realistic custom UI, or exercised the headless APIs without the default UI.

What it adds

  • tools/storybook/stories/core/custom-host.stories.tsx (Core/Custom host): a whole host UI in plain elements, importing only @githubnext/projections-host. It has:

    • views from useViewChoice, as a radio group, plus a table of visibleRows for the built-in views;
    • visibility from viewControls;
    • mode and scope radio groups (scopeChoice, including the "nothing hidden" note) with arrows, Home and End from rovingIndex;
    • a play button named by playButton, the slider, and Space from the toolbar (handlePlaybackShortcut);
    • find;
    • the summary's figures as filter toggles (summaryToggle, summaryToggleTitle).

    The stories are Animated, Side by side and One extraction. Everything in the file is presentation.

  • tools/storybook/browser/custom-host.spec.ts: Space from the toolbar plays and pauses; End in the view switch moves to Text and focuses it; playback stays beside the text view in Animated.

    The smoke suite also renders each story without console errors.

  • docs/guides/embedding.md and the Storybook README point to it.

It serves as a conformance check too: the story fails to type-check if a headless API it relies on changes shape.

Checks

  • tools check --fast: pass.
  • The story type-checks in the Storybook program. The program's other errors come from renderers that aren't built here.
  • Browser specs run in CI.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Summary facts without item IDs hide all rows when clicked, and activating an already-selected row does not clear selection despite its toggle semantics.

2 open issues
What changed in this PR

Adds a complete Storybook example showing how to build a custom host UI using the headless core without a UI package.

Changes:

  • Demonstrates view, mode, scope, playback, search, row selection, and summary controls across three stories.
  • Adds browser coverage for Space playback, keyboard view selection, and playback availability in the text view.
  • Links the example from the embedding guide and Storybook README.
File Description
tools/​storybook/​stories/​core/​custom-host.stories.tsx Adds the custom host UI and three story variants.
tools/​storybook/​README.md Lists the example and its demonstrated APIs.
tools/​storybook/​browser/​custom-host.spec.ts Tests keyboard controls and playback visibility.
docs/​guides/​embedding.md Points embedding developers to the complete example.

Review effort: Balanced

@agorischek
agorischek force-pushed the custom-host-story branch 2 times, most recently from 7139040 to e76b42b Compare November 21, 2026 01:08
@agorischek
agorischek force-pushed the pane-band-inset branch 2 times, most recently from a3aaa45 to 747c30e Compare November 21, 2026 01:37
@agorischek
agorischek force-pushed the custom-host-story branch 2 times, most recently from 913cebe to ddb61e9 Compare November 21, 2026 16:08
@agorischek
agorischek force-pushed the pane-band-inset branch 2 times, most recently from 243349f to 7c92224 Compare November 21, 2026 19:07
agorischek and others added 6 commits November 21, 2026 12:34
The rule for when a running job's indicator shows (after 300 ms, then for at least 400 ms) lived in the VS Code UI,
so the default UI's "Updating…" chip showed for every job, however short. The rule is now the core's:
`runningIndicator` and its constants at `@githubnext/projections-host/running` (no React or DOM, for the VS Code
extension host), and `useRunningIndicator`, which the default UI's chip and the VS Code UI's summary bar both use. The
VS Code UI's `./running` entry re-exports it, so the extension is unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The running indicator's minimum started while a loading pane kept the chip hidden, so a chip revealed as the renderer
became ready could vanish at once. The latch now lives only while no pane is loading.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The Inspector wrote revision labels as `name · detail · when`, and four places read them back by splitting on ` · `
with their own rules: the default UI's and the VS Code UI's pair pickers (one trimmed, one didn't), the pane chips
(with an age heuristic) and the pane label bands. The core now owns the format: `formatRevisionLabel`,
`parseRevisionLabel`, `revisionLabelName` and `revisionAge` (the Inspector's `age`, moved). Every reader and the
Inspector's writer use them; `shortRevisionLabel` and the Inspector's `age` keep their names.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The pane label band (side by side's and swipe's revision headers) set `padding: 0 10px` inline, so a host lining its
labels up with its own layout had to override the band with `!important`, as the Playground's Primer UI does. The band
now reads `--pj-pane-band-inset` (10px by default), or `--pj-pane-band-inset-start` and `-end` apart, beside its
existing `--pj-pane-band-bg`, `-fg` and `-rule`.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
`Core/Custom host` is the example a team with its own design system starts from: plain elements, no UI package, and
every decision the core's (`useViewChoice`, `viewControls`, `scopeChoice`, `playButton`, the Space shortcut,
`rovingIndex`, `summaryToggle`), so it behaves as the default and VS Code UIs do. The smoke suite renders it like
every story, and a small spec checks Space from its toolbar and the arrow keys in its view switch. The embedding guide
points to it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… row clears on a second press

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Base automatically changed from pane-band-inset to main November 21, 2026 22:29
@agorischek
agorischek merged commit 2340d77 into main Nov 21, 2026
33 checks passed
@agorischek
agorischek deleted the custom-host-story branch November 21, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants